<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="cn.bdqn.pojo.News"%>
<%@page import="cn.bdqn.pojo.NewsCategory"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../common/common.jsp" %> 
<html>
	<head>
		<link href="<%=request.getContextPath() %>/css/common.css" rel="stylesheet" type="text/css" />
		<script src="<%=request.getContextPath()%>/ckeditor/ckeditor.js"></script>
	</head>
<body>
<%
	//根据新闻ID获取新闻明细
	News news = new News();
	news.setId(Integer.valueOf(request.getParameter("id")));
	news = newsService.getNewsById(news);
	
	//获取新闻分类信息列表
	List<NewsCategory> newsCategoryList = newsCategoryService.getNewsCategoryList();
%>
<form name ="dataForm" id="dataForm" action="doEdit.jsp" method="post" enctype="multipart/form-data">
	<table  width="100%" border="0" cellspacing="5" cellpadding="0">
		<thead>
			<tr><td align="center" colspan="2" class="text_tabledetail2">增加新闻</td></tr>
		</thead>
		<tbody>
			<tr>
				<input type="hidden" name="id" id="id" value="<%=news.getId() %>"/>
				<td style="text-align:right;" class="text_tabledetail2">分类</td>
				<td style="text-align:left;">
				<!-- 列出所有的新闻分类 -->
				<select name="categoryId">
				    <option value="">--请选择--</option>
					 <%for(NewsCategory newsCategory:newsCategoryList){%>
					   	<option 
					   		<%if(newsCategory.getId() == news.getCategoryId()){%> selected="selected" <%} %>
					   		value="<%=newsCategory.getId() %>"><%=newsCategory.getName() %>
					   	</option>
					 <%} %>
        		</select>
				</td>
			</tr>
			<tr>
				<td style="text-align:right;" class="text_tabledetail2">标题</td>
				<td style="text-align:left;"><input type="text" name="title" value="<%=news.getTitle()%>"/></td>
			</tr>
			<tr>
				<td style="text-align:right;" class="text_tabledetail2">作者</td>
				<td style="text-align:left;"><input type="text" name="author" value="<%=news.getAuthor()%>"/></td>
			</tr>
			
			<tr>
				<td style="text-align:right;" class="text_tabledetail2">摘要</td>
				<td style="text-align:left;"><textarea id="summary" name="summary" rows="8" cols="50"><%=news.getSummary() %></textarea></td>
			</tr>
			<tr>
				<td style="text-align:right;" class="text_tabledetail2">内容</td>
				<td style="text-align:left;">
				<div id="xToolbar"></div>
				<textarea id="newscontent" name="newscontent" rows="8" cols="30" class="ckeditor"><%=news.getContent() %></textarea></td>
			</tr>
			<tr>
				<td style="text-align:right;" class="text_tabledetail2">上传图片 </td>
				<%if(news.getPicPath() == null){ %>
					<td style="text-align:left;"><input type="file" name="picPath" value=""/></td>
				<%}else{%>
					<td style="text-align:left;">
						<img src="<%=request.getContextPath() %>/upload/<%=news.getPicPath()%>"/>
					</td>
				<%} %>
			</tr>
			<tr>
				<td style="text-align:center;" colspan="2">
					<button type="submit" class="page-btn" name="save">保存</button>
					<button type="button" class="page-btn" name="return" onclick="javascript:location.href='newsDetailList.jsp'">返回</button>
				</td>
			</tr>
		</tbody>
	</table>
</form>
</body>
</html>